function search() {
    var $res = $('#result');
    $res.html('');
    var from = $('#fromStation').val();
    var to = $('#toStation').val();
    var date = $('#trainDate').val();
    
    $.ajax({
        url: './search',
        type: 'post',
        data: {
            fromStation: from,
            toStation: to,
            trainDate: date
        },
        success: function (data) {
            console.log(data);
            if(data === 'failed'){
                alert("请求失败");
            }else{
                
                data.forEach(element => {
                    $res.append('<tr>'+
                    '<td>'+element.train+'</td>'+
                    '<td>'+element.start_time+'/'+element.end_time+'</td>'+
                    '<td>'+element.train_consuming+'</td>'+
                    '<td>'+element.A9+'</td>'+
                    '<td>'+element.M+'</td>'+
                    '<td>'+element.O+'</td>'+
                    '<td>'+element.A6+'</td>'+
                    '<td>'+element.A4+'</td>'+
                    '<td>'+element.F+'</td>'+
                    '<td>'+element.A3+'</td>'+
                    '<td>'+element.A1+'</td>'+
                    '<td>'+element.WZ+'</td>'+
                    '</tr>');
                });
                return true;
            }
        },
        error: function (err) {
            console.log("error!!!");
          }
    });
}